/**
 * 显示简历的个人信息部分
 */
function show_basic_info(){
	$('#basic_info').show();
	window.href = "#basic_info";
}

/**
 * 显示简历的教育背景部分
 */
function show_edu_background(){
	$('#edu_background').show();
}

/**
 * 显示简历的项目经验部分
 */
function show_project_experience(){
	$('#project_experience').show();
}

/**
 * 显示简历的专业技能部分
 */
function show_profess_skill(){
	$('#profess_skill').show();
}

/**
 * 显示简历的社会实践部分
 */
function show_social_practice(){
	$('#social_practice').show();
}

/**
 * 显示简历的获奖情况部分
 */
function show_awards(){
	$('#awarding').show();
}

/**
 * 显示简历的自我评价部分
 */
function show_self_evaluation(){
	$('#self_evaluation').show();
	window.href = "#self_evaluation";
}

/**
 * 提交简历表单
 */

$.validator.setDefaults({
	submitHandler : function(form) {
	
		var id = $("#id").val();
		var url = "saveResumeAction.html";
		var returnUrl = "list.html";
		if (id) {
			url = "../" + url;
			returnUrl = "../" + returnUrl;
		}
		var entity = {
			id : id,
			name : $("#name").val(),
			age: $("#age").val(),
			sex:$("#sex").val(),
			birthplace : $("#birthplace").val(),
			birthday:$("#birthday").val(),
			nation : $("#nation").val(),
			phone : $("#phone").val(),
			email : $("#email").val(),
			school: $("#school").val(),
			major : $("#major").val(),
			education:$("#education").val(),
			jobApplied : $("#jobApplied").val(),
			address: $("#address").val(),
			eduBackground: $("#eduBackground").val(),
			professSkill: $("#professSkill").val(),
			projectExperience: $("#projectExperience").val(),
			socialPractice: $("#socialPractice").val(),
			awards: $("#awards").val(),
			selfEvaluation: $("#selfEvaluation").val()
		};
		var onloadFunc = function(result) {
			if (result.isSuccess == true) {
				window.location = returnUrl;
			} else {
				alert(result.message);
			}
		};
		httpRequestPostJson(url, entity, true, onloadFunc);
	}

});

/**
 * 验证简历表单
 */
var validator = $("#myForm").validate({
	success : function(label) {
		label.addClass('ok');
	},
	rules : {
		name: {
			required : true,
			rangelength : [ 1, 30 ]
		},
		age: {
			required : true
		},
		birthplace: {
			required : true
		},
		nation: {
			required : true
		},
		phone: {
			required : true
		},
		email: {
			required : true
		},
		school: {
			required : true
		},
		major: {
			required : true
		},
		jobApplied: {
			required : true,
			rangelength : [ 2, 30 ]
		},
		address: {
			required : true
		},
		eduBackground: {
		},
		project_experience: {
			required : true
		},
		profess_skill: {
			required : true
		},
		socialPractice: {
			required : true
		},
		awards: {
			required : true,
			rangelength : [ 2, 30 ]
		},
		self_evaluation: {
			required : true
		}		
	},
	messages : {
		name: {
			required : "请输入您的真实姓名",
			rangelength : "姓名长度1-30位"
		},
		age: {
			required : "请输入您的年龄"
		},
		birthplace: {
			required : "请输入您的籍贯"
		},
		nation: {
			required : "请输入您的民族"
		},
		phone: {
			required : "请输入您的手机号码",
		},
		email: {
			required : "请输入您的邮箱地址"
		},
		school: {
			required : "请输入您的毕业学校"
		},
		major: {
			required : "请输入您的专业名称"
		},
		nation: {
			required : "请输入您的民族"
		},
		jobApplied: {
			required : "请输入您的应聘职位",
		},
		address: {
			required : "请输入您的联系地址"
		}
	}
});

